
#include "oglutils.h"

void checkGLErrors(const char *label) {
   
   GLenum errCode;
   const GLubyte *errStr;
   
   if ((errCode = glGetError()) != GL_NO_ERROR) {
      errStr = gluErrorString(errCode);
      printf("OpenGL ERROR: ");
      printf((char*)errStr);
      printf("(Label: ");
      printf(label);
      printf(")\n.");
   }
}

/// error checking for GLSL, copied directly from the spec
void printInfoLog(GLhandleARB obj) {
   
   int infologLength = 0;
   int charsWritten  = 0;
   char *infoLog;
   glGetObjectParameterivARB(obj, GL_OBJECT_INFO_LOG_LENGTH_ARB, &infologLength);
   if (infologLength > 1) {
      infoLog = (char*)malloc(infologLength);
      glGetInfoLogARB(obj, infologLength, &charsWritten, infoLog);
      printf(infoLog);
      printf("\n");
      free(infoLog);
   }
}
